[Core] Reschedule leases in local lease manager when draining the node#57834
Merged
jjyao merged 6 commits intoray-project:masterfrom Oct 19, 2025
Merged
[Core] Reschedule leases in local lease manager when draining the node#57834jjyao merged 6 commits intoray-project:masterfrom
jjyao merged 6 commits intoray-project:masterfrom
Conversation
Signed-off-by: Jiajun Yao <jeromeyjj@gmail.com>
jjyao
commented
Oct 17, 2025
Comment on lines
+35
to
+46
| namespace { | ||
| void ReplyCancelled(const std::shared_ptr<internal::Work> &work, | ||
| rpc::RequestWorkerLeaseReply::SchedulingFailureType failure_type, | ||
| const std::string &scheduling_failure_message) { | ||
| auto reply = work->reply_; | ||
| reply->set_canceled(true); | ||
| reply->set_failure_type(failure_type); | ||
| reply->set_scheduling_failure_message(scheduling_failure_message); | ||
| work->send_reply_callback_(Status::OK(), nullptr, nullptr); | ||
| } | ||
| } // namespace | ||
|
|
src/ray/raylet/node_manager.cc
Outdated
Comment on lines
2082
to
2096
| if (reply->is_accepted()) { | ||
| // Fail fast on the leases in the local lease maanger | ||
| // and add them back to the cluster lease manager so a new node | ||
| // can be selected by the scheduler. | ||
| auto cancelled_works = local_lease_manager_.CancelLeasesWithoutReply( | ||
| [&](const std::shared_ptr<internal::Work> &work) { return true; }); | ||
| for (const auto &work : cancelled_works) { | ||
| cluster_lease_manager_.QueueAndScheduleLease(work->lease_, | ||
| work->grant_or_reject_, | ||
| work->is_selected_based_on_locality_, | ||
| work->reply_, | ||
| work->send_reply_callback_); | ||
| } | ||
| } | ||
|
|
dayshah
approved these changes
Oct 18, 2025
Contributor
dayshah
left a comment
There was a problem hiding this comment.
logic lgtm, nits
Python integration test looks a little prone to flakiness, probably not necessary to test this from python
justinyeh1995
pushed a commit
to justinyeh1995/ray
that referenced
this pull request
Oct 20, 2025
ray-project#57834) Signed-off-by: Jiajun Yao <jeromeyjj@gmail.com>
xinyuangui2
pushed a commit
to xinyuangui2/ray
that referenced
this pull request
Oct 22, 2025
ray-project#57834) Signed-off-by: Jiajun Yao <jeromeyjj@gmail.com> Signed-off-by: xgui <xgui@anyscale.com>
elliot-barn
pushed a commit
that referenced
this pull request
Oct 23, 2025
#57834) Signed-off-by: Jiajun Yao <jeromeyjj@gmail.com> Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
landscapepainter
pushed a commit
to landscapepainter/ray
that referenced
this pull request
Nov 17, 2025
ray-project#57834) Signed-off-by: Jiajun Yao <jeromeyjj@gmail.com>
Aydin-ab
pushed a commit
to Aydin-ab/ray-aydin
that referenced
this pull request
Nov 19, 2025
ray-project#57834) Signed-off-by: Jiajun Yao <jeromeyjj@gmail.com> Signed-off-by: Aydin Abiar <aydin@anyscale.com>
Future-Outlier
pushed a commit
to Future-Outlier/ray
that referenced
this pull request
Dec 7, 2025
ray-project#57834) Signed-off-by: Jiajun Yao <jeromeyjj@gmail.com> Signed-off-by: Future-Outlier <eric901201@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Symptom
and task fails with
TaskUnschedulableErrorRoot Cause
In master, we assumed that once a lease request is added to the local lease manager, the lease cannot become infeasible. It turned out to be not true since a node can be drained and once a node is in the draining state, it's excluded from the scheduling decision and a lease can now become infeasible (if the draining node was the only feasible node in the cluster).
Fix
When a node is being drained, we should fail fast on all leases that are in the local lease manager regardless whether they are waiting for workers, pulling args or what and add them back to the cluster lease manager so scheduler can run the scheduling logic again to find a new node.